package test03;

import java.util.Arrays;
import java.util.Scanner;

public class Test03 {
    public static void main(String[] args) {
        //1.定义一个数组,准备一些已经存在的数据
        double[] oldPrice = {23.6,34.4,35.3,36.2,78.8,89.6,100.3};
        //2.创建Scanner对象
        Scanner sc = new Scanner(System.in);
        System.out.println("请你输入一个新的价格:");
        double price = sc.nextDouble();
        //3.创建新的数组
        double[] newPrice = new double[oldPrice.length+1];

        //4.利用System中的赋值数组元素的方法,去将老数组中的数据复制到新数组中
        System.arraycopy(oldPrice,0,newPrice,0,oldPrice.length);

        newPrice[newPrice.length-1] = price;

        //5.排序
        Arrays.sort(newPrice);

        System.out.println(Arrays.toString(newPrice));
    }
}
